package com.yayan.xh.service;

import java.util.List;
import java.util.Map;

import org.springframework.stereotype.Service;

import com.yayan.xh.bean.GradeBean;
import com.yayan.xh.dao.GradeDao;
import com.yayan.xh.dao.IGradeDao;

@Service
public class GradeService implements IGradeService {
	
	private IGradeDao gradeDao;
	
	public GradeService() {
		gradeDao = new GradeDao();
	}

	@Override
	public List<GradeBean> getGradeList(Map<String, String> map) {
		List<GradeBean> list = null;
		try {
			if(null != map.get("shopId") && !"0".equalsIgnoreCase(map.get("shopId"))) {
				list = gradeDao.getGradeList(map);
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
		return list;
	}

	@Override
	public GradeBean getGradeById(Map<String, String> map) {
		GradeBean bean = null;
		try {
			if(null != map.get("shopId") && null != map.get("gradeId") 
					&& !"0".equalsIgnoreCase(map.get("shopId")) && !"0".equalsIgnoreCase(map.get("gradeId"))) {
				bean = gradeDao.getGradeById(map);
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
		return bean;
	}

	@Override
	public boolean saveGrade(Map<String, String> map) {
		boolean f = false;
		try {
			if(null != map.get("shopId")  && !"0".equalsIgnoreCase(map.get("shopId"))) {
				f = gradeDao.saveGrade(map);
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
		return f;
	}

	@Override
	public boolean modifyGrade(Map<String, String> map) {
		boolean f = false;
		try {
			if(null != map.get("shopId") && null != map.get("gradeId") 
					&& !"0".equalsIgnoreCase(map.get("shopId")) && !"0".equalsIgnoreCase(map.get("gradeId"))) {
				f = gradeDao.modifyGrade(map);
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
		return f;
	}

	@Override
	public boolean delGrade(Map<String, String> map) {
		boolean f = false;
		try {
			if(null != map.get("shopId") && null != map.get("gradeId") 
					&& !"0".equalsIgnoreCase(map.get("shopId")) && !"0".equalsIgnoreCase(map.get("gradeId"))) {
				f = gradeDao.delGrade(map);
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
		return f;
	}

}
